function [ mpc ] = mpc_pitch_ref( sys, x, u, k, param )
ref=param.ref;
mpc=InitMPC(sys,100*eye(),1*eye(),1000000);
nSample=20;

len=length(ref);
if((k+nSample)<=len)
    ref=ref(k:k+nSample-1);
else
    if(k<len)
        ref=ref(k:end);
    else
        ref=ref(1:nSample);
        ref(1:nSample)=0;
    end
    ref(nSample)=0;
end

ref=ref';

mpc=MPCSampling(mpc,nSample,nSample,[]);
mpc=MPCHardBounds(mpc,createBounds(sys,nSample,[-100],[],-1),createBounds(sys,nSample,[100],[],1));%,ref-10,1:nSample);
mpc=MPCSoftBounds(mpc,ref-10,ref+10,1:nSample);
mpc=addMPCstate(mpc,x);
mpc=addMPCcontrol(mpc,u);
mpc=addMPCref(mpc,ref);
end

